from odoo import models, fields, api
from odoo import exceptions # will be used in the code
import logging
_logger = logging.getLogger(__name__)

class OperatorWizard(models.TransientModel):
    _name = 'meas.ctl.operator.wizard'
    company_id=fields.Many2one('res.company',default=lambda self: self.env.company.id) 
    # operator_id=fields.Many2one('res.users',domain="[('company_id','=',company_id)]") #只选当前公司的用户
    operator_id=fields.Many2one('res.users',domain= lambda self:[('company_id','=',self.env.company.id)]) #只选当前公司的用户
    
    def operator_action(self):
        company_id=self.env.company.id
        active_id=self.env.context['active_id']
        active_model=self.env.context['active_model']
        self.env['meas.main.sub'].search([('dispatch','=',True),('company_id','=',company_id)]).update({'operator_id':self.operator_id.id})
        self.env[active_model].browse(active_id).update({'to_xls':True})
        
